using System;
using System.Data;
using System.Linq;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using DataObject.Database;
using DataObject.Model;

public partial class ReservationDetailMapper
{
    #region ToSingle

    public static ReservationDetailDTO ToSingle(ReservationDetail entity)
    {
        if (entity == null)
        {
            return null;
        }
        return new ReservationDetailDTO
        {
            CabinID = entity.CabinID,
            CabinPrice = entity.CabinPrice,
            CabinStatus = entity.CabinStatus,
            Note = entity.Note,
            NumOfPeople = entity.NumOfPeople,
            RDID = entity.RDID,
            Representative = entity.Representative,
            ReservationID = entity.ReservationID,
            Status = entity.Status,
            UnitPrice = entity.UnitPrice
        };
    }

    #endregion

    #region ToEntity

    public static ReservationDetail ToEntity(ReservationDetail entity, ReservationDetailDTO businessobject)
    {
        if (businessobject == null)
        {
            return null;
        }
        entity.CabinID = businessobject.CabinID;
        entity.CabinPrice = businessobject.CabinPrice;
        entity.UnitPrice = businessobject.UnitPrice;
        entity.CabinStatus = businessobject.CabinStatus;
        entity.Note = businessobject.Note;
        entity.NumOfPeople = businessobject.NumOfPeople;
        entity.RDID = businessobject.RDID;
        entity.Representative = businessobject.Representative;
        entity.ReservationID = businessobject.ReservationID;
        entity.Status = businessobject.Status;
        return entity;
    }

    #endregion

    #region ToBusinessObject

    public static ReservationDetailDTO ToBusinessObject(ReservationDetail entity)
    {
        if (entity == null)
        {
            return null;
        }
        return new ReservationDetailDTO
        {
            CabinID = entity.CabinID,
            CabinPrice = entity.CabinPrice,
            UnitPrice = entity.UnitPrice,
            CabinStatus = entity.CabinStatus,
            Note = entity.Note,
            NumOfPeople = entity.NumOfPeople,
            RDID = entity.RDID,
            Representative = entity.Representative,
            ReservationID = entity.ReservationID,
            Status = entity.Status,
            Reservation = ReservationMapper.ToBusinessObject(entity.Reservation),
        };
    }

    #endregion

    #region ToBusinessObjectHasChildren

    public static ReservationDetailDTO ToBusinessObjectHasChildren(ReservationDetail entity, params Type[] types)
    {
        if (entity == null)
        {
            return null;
        }
        ReservationDetailDTO businessobject = new ReservationDetailDTO
        {
            CabinID = entity.CabinID,
            CabinPrice = entity.CabinPrice,
            UnitPrice = entity.UnitPrice,
            CabinStatus = entity.CabinStatus,
            Note = entity.Note,
            NumOfPeople = entity.NumOfPeople,
            RDID = entity.RDID,
            Representative = entity.Representative,
            ReservationID = entity.ReservationID,
            Status = entity.Status,
            Reservation = ReservationMapper.ToBusinessObject(entity.Reservation),
        };
        if (types.Contains<Type>(typeof(CabinStatus)) || types.Length == 0)
        {
            businessobject.CabinStatusCollection = new List<CabinStatusDTO>();
            foreach (var item in entity.CabinStatusEntities)
            {
                businessobject.CabinStatusCollection.Add(CabinStatusMapper.ToBusinessObject(item));
            }
        }
        return businessobject;
    }

    #endregion

}
